//...
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;



typedef struct aaaaaa{
	int w, f, c;
}comp;


vector<comp> v[1000];
int dp[1000], l, n, b, i, j, x0;
comp a;


int rec(int x){
	
}

int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	memset(dp,0,sizeof(dp));
	scanf("%d%d%d", &l, &n, &b);
	for(i=0;i<n;++i){
		scanf("%d%d%d%d", &x0, &a.w, &a.f, &a.c);
		v[x0].push_back(a);
	}
	printf("%d\n",rec(0, 0));
	return 0;
}
